
import java.io.Closeable;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Reader;

public class LexicalAnalysisInput {
    // 这个类是处理词法分析输入的，将文件转换成为字符串。
    static String input() {
        String path = Config.lexInputPath;
        String content = "";
        try {
           // File file = new File(path);
        
            //content = Files.readString(Paths.get(path));
            content = readFromTxt(path);
            System.out.println(content);
//            System.out.println(content);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
        return content;
    }
    private static String readFromTxt(String filename) throws Exception {
		Reader reader = null;
		try {
			StringBuffer buf = new StringBuffer();
			char[] chars = new char[1024];
			// InputStream in=new FileInputStream(filename);

			reader = new InputStreamReader(new FileInputStream(filename), "UTF-8");
			int readed = reader.read(chars);
			while (readed != -1) {
				buf.append(chars, 0, readed);
				readed = reader.read(chars);
			}
			return buf.toString();
		} finally {
			close(reader);
		}
        
    }
    private static void close(Closeable inout) {
		if (inout != null) {
			try {
				inout.close();
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
	}
}
